import {Outlet, useLocation, useNavigate} from "react-router-dom";

const Home = () => {
    const location = useLocation();
    const navigate = useNavigate();
    return (
        <div>
            <h2>我是Home页</h2>
            <button onClick={() => {
                navigate("news", {state: {id: "001", title: "新闻标题", content: "新闻内容"}})
            }}>新闻
            </button>
            <h3>{location.state.name}</h3>
            <h3>{location.state.age}</h3>
            <h3>{location.state.sex}</h3>
            <div style={{backgroundColor: "yellowgreen"}}>
                <Outlet/>
            </div>
        </div>
    )
}

export default Home
